package cn.ren.cloud.fallback;

import cn.ren.cloud.doc.EsCourseDoc;
import cn.ren.cloud.enums.GlobelExceptionEnum;
import cn.ren.cloud.feign.EsCourseFeignClient;
import cn.ren.cloud.result.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author 23508
 */
@Component
public class EsCourseFeignClientFallbackFactory implements FallbackFactory<EsCourseFeignClient> {
    @Override
    public EsCourseFeignClient create(Throwable throwable) {
        return new EsCourseFeignClient() {
            @Override
            public JsonResult saveCourseEs(EsCourseDoc courseEs) {
                return JsonResult.error(GlobelExceptionEnum.COMMON_REPEAT_OPERATION_ERROR.getMessage(), GlobelExceptionEnum.COMMON_REPEAT_OPERATION_ERROR.getCode());
            }
        };
    }
}
